/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package parismetro;

import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.Group;
import javafx.scene.text.TextAlignment;
import javafx.scene.Node;
import javafx.scene.CustomNode;
import javafx.scene.input.MouseEvent;
import javafx.scene.CacheHint;

/**
 * @author Hadrien
 */
public class OptionEcran extends CustomNode {

    var group: Group;
    public var main: Main;
    public var previousStep = "accueil";
    public var previousStep2 = "accueil";

    def backGround2 = ImageView {
                image: Image { url: "{__DIR__}icons/back_1-2.png" } }
    var cart = Cart{
        orderList: main.orderList;
        layoutX:5
        layoutY:5
    }

    def bouton_pay = Group {
                layoutX: 5;
                layoutY: 435;
                visible: bind Main.orderList.orders.size() > 0
                content: [
                    Rectangle {
                        height: 100
                        width: 220
                        arcWidth: 20, arcHeight: 20
                        fill: Color.rgb(0, 169, 157)
                        stroke: Color.WHITE;
                        strokeWidth: 5;
                    }
                    Text {
                        layoutX: 30, layoutY: 40
                        font: Font { size: 32, embolden: true, name: "Myriad Pro" }
                        content: "Payer ma\ncommande"
                        textAlignment: TextAlignment.CENTER
                        fill: Color.WHITE
                    }
                ]
                onMousePressed: function(e: MouseEvent): Void {
                    main.logger.addEvent("tplus", "btnPay", "paiement");
                    main.optionEcran.previousStep2 = "tplus";
                    main.changeContent("paiement")
                }
            }
    def bouton_annuler_tout = Group {
                layoutX: 10;
                layoutY: 644;
                //effect: shadow;
                content: [
                    Rectangle {
                        height: 95
                        width: 100
                        arcWidth: 15, arcHeight: 15
                        fill: Color.rgb(255, 115, 89)
                        stroke: Color.WHITE;
                        strokeWidth: 5;
                    }
                    Text {
                        layoutX: 10, layoutY: 40
                        font: Font { size: 22, embolden: true, name: "Myriad Pro" }
                        content: "Annuler\nTout"
                        textAlignment: TextAlignment.CENTER
                        fill: Color.WHITE
                    }
                ]
                onMousePressed: function(e: MouseEvent): Void {
                    main.logger.addEvent("tplus", "btnAnnulerTout", "accueil");
                    main.orderList.removeAll();
                    main.changeContent("accueil");
                }
            }
    def bouton_etape_prec = Group {
                layoutX: 120;
                layoutY: 644;
                //effect: shadow;
                content: [
                    Rectangle {
                        height: 95
                        width: 102
                        arcWidth: 15, arcHeight: 15
                        fill: Color.rgb(0, 113, 188)
                        stroke: Color.WHITE;
                        strokeWidth: 5;
                    }
                    Text {
                        layoutX: 1, layoutY: 40
                        font: Font { size: 19, embolden: true, name: "Myriad Pro" }
                        content: "Etape\nPrécédente"
                        textAlignment: TextAlignment.CENTER
                        fill: Color.WHITE
                    }
                ]
                onMousePressed: function(e: MouseEvent): Void {
                    main.logger.addEvent("tplus", "btnEtapePrec", previousStep);
                    main.orderList.removeLast();
                    main.changeContent(previousStep);
                }
            }
    def bouton_autres_tickets = Group {
                layoutX: 5;
                layoutY: 540;
                //effect: shadow;
                content: [
                    Rectangle {
                        height: 100
                        width: 220
                        arcWidth: 20, arcHeight: 20
                        fill: Color.rgb(0, 113, 188)
                        stroke: Color.WHITE;
                        strokeWidth: 5;
                    }
                    Text {
                        layoutX: 10, layoutY: 40
                        //wrappingWidth:200
                        font: Font { size: 28, embolden: true, name: "Myriad Pro" }
                        content: "Acheter d'autres\nTickets"
                        textAlignment: TextAlignment.CENTER
                        fill: Color.WHITE
                    }
                ]
                onMousePressed: function(e: MouseEvent): Void {
                    main.logger.addEvent("tplus", "btnAutresTickets", "accueil");
                    main.changeContent("accueil");
                }
            }

    def cadre_nombre_tickets = Group {
                content: [
                    Rectangle {
                        width: 210
                        height: 545
                        arcWidth: 20, arcHeight: 20
                        fill: Color.rgb(0, 142, 250)
                    }
                    Text {
                        x: 15, layoutY: 30
                        font: Font { size: 24, embolden: true, name: "Myriad Pro" }
                        content: "Nombre de tickets"
                        textAlignment: TextAlignment.CENTER
                        fill: Color.WHITE
                    }
                ]
                layoutX: 785;
                layoutY: 20;
            }
    def cadre_nombre_carnets = Group {
                layoutX: 320;
                layoutY: 545;
                content: [
                    Rectangle {
                        height: 170
                        width: 216
                        arcWidth: 15, arcHeight: 15
                        fill: Color.rgb(113, 206, 102)
                    }
                    Text {
                        layoutX: 7, layoutY: 30
                        font: Font { size: 24, embolden: true, name: "Myriad Pro", }
                        content: "Nombre de carnets\n10 Tickets"
                        textAlignment: TextAlignment.CENTER
                        fill: Color.WHITE
                    }
                ]
            }
    def fare = ButtonsFare {
                layoutX: 268;
                layoutY: 25;
            }

    def un = ButtonQuantity {
                layoutX: 793;
                layoutY: 60;
                number: 1;
            }
    def deux = ButtonQuantity {
                layoutX: 893;
                layoutY: 60;
                number: 2;
            }
    def trois = ButtonQuantity {
                layoutX: 793;
                layoutY: 160;
                number: 3;
            }
    def quatre = ButtonQuantity {
                layoutX: 893;
                layoutY: 160;
                number: 4;
            }
    def cinq = ButtonQuantity {
                layoutX: 793;
                layoutY: 260;
                number: 5;
            }
    def six = ButtonQuantity {
                layoutX: 893;
                layoutY: 260;
                number: 6;
            }
    def sept = ButtonQuantity {
                layoutX: 793;
                layoutY: 360;
                number: 7;
            }
    def huit = ButtonQuantity {
                layoutX: 893;
                layoutY: 360;
                number: 8;
            }
    def neuf = ButtonQuantity {
                layoutX: 793;
                layoutY: 460;
                number: 9;
            }
    def un_carnet = ButtonBook {
                layoutX: 328;
                layoutY: 613;
                number: 1;
            }
    def deux_carnets = ButtonBook {
                layoutX: 432;
                layoutY: 613;
                number: 2;
            }

    override public function create(): Node {
        group = Group { content: [
                        backGround2,
                        cart,
                        cadre_nombre_tickets,
                        cadre_nombre_carnets,
                        bouton_autres_tickets, fare,
                        un, deux, trois, quatre, cinq, six, sept, huit, neuf,
                        bouton_pay,
                        un_carnet, deux_carnets, bouton_annuler_tout, bouton_etape_prec

                    ]
                    cache:true;
                    cacheHint: CacheHint.SPEED;
                }
        return group;
    }

}
